package com.spzx.product.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.product.api.domain.Product;
import com.spzx.product.api.domain.ProductDetails;
import com.spzx.product.api.domain.ProductSku;
import com.spzx.product.api.domain.vo.SkuPriceVo;
import com.spzx.product.api.domain.vo.SkuStockVo;
import com.spzx.product.api.service.RemoteProductSkuService;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;
import java.util.Map;

public class RemoteProductSkuFallbackFactory implements FallbackFactory<RemoteProductSkuService> {

    @Override
    public RemoteProductSkuService create(Throwable cause) {
        return new RemoteProductSkuService() {
            @Override
            public R<List<ProductSku>> getTopProductSku(String source) {
                return R.fail("远程调用微服务失败"+cause.getMessage());
            }

            @Override
            public R<ProductSku> getProductSkuById(Long id, String source) {
                return R.fail("远程调用微服务失败"+cause.getMessage());
            }

            @Override
            public R<Product> getProductById(Long id, String source) {
                return R.fail("远程调用微服务失败"+cause.getMessage());
            }

            @Override
            public R<SkuPriceVo> getSkuPriceVoBySkuId(Long skuId, String source) {
                return R.fail("远程调用微服务失败"+cause.getMessage());
            }

            @Override
            public R<ProductDetails> getProductDetails(Long id, String source) {
                return R.fail("远程调用微服务失败"+cause.getMessage());
            }

            @Override
            public R<Map<String, Long>> getSkuSpecValue(Long id, String source) {
                return R.fail("远程调用微服务失败"+cause.getMessage());
            }

            @Override
            public R<SkuStockVo> getSkuStock(Long skuId, String source) {
                return R.fail("远程调用微服务失败"+cause.getMessage());
            }

            /*@Override
            public R<ProductSku> getProductSkuById(Long id) {
                return R.fail("远程调用获取sku信息失败"+cause.getMessage());
            }

            @Override
            public R<Product> getProductById(Long id) {
                return R.fail("远程调用获取商品信息失败"+cause.getMessage());
            }

            @Override
            public R<SkuPriceVo> getSkuPriceVoBySkuId(Long skuId) {
                return R.fail("远程调用规格价格失败"+cause.getMessage());
            }

            @Override
            public R<ProductDetails> getProductDetails(Long id) {
                return R.fail("远程调用获取商品详情失败"+cause.getMessage());
            }

            @Override
            public R<Map<String, Long>> getSkuSpecValue(Long id) {
                return R.fail("远程调用SkuSpec失败"+cause.getMessage());
            }

            @Override
            public R<SkuStockVo> getSkuStock(Long skuId) {
                return R.fail("远程调用SkuStock失败"+cause.getMessage());
            }*/
        };
    }
}
